#include<bits/stdc++.h>
using namespace std;
long long T,n,m,L,V;
long long d[100010],v[100010],a[100010],p[100010],st[100010];
bool zero;
struct ra{
	int b;
	int e;
};
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin>>T;
	while(T--){
		cin>>n>>m>>L>>V;
		int ans1=0;
		vector<ra> r;
		zero=0;
		for(int i=0;i<n;i++){
			cin>>d[i]>>v[i]>>a[i];
		}
		for(int i=0;i<m;i++){
			cin>>p[i];
			st[m]=0;
		}
		for(int i=0;i<n;i++){
			if(a[i]==0&&d[i]<=p[m-1]){
				if(v[i]>V){
					ans1++;
					zero=1;
					int first=-1;
					bool f,f1=0;
					for(int h=0;h<m;h++){
						if(p[h]>d[i]&&f1==0){
							first=h;
							f1=1;
							break;
						}
					}
					f=0;
					for(int j=0;j<(int)r.size();j++){
						if(first>r[j].e){
							continue;
						}else{
							f=1;
							r[j].b=max(r[j].b,first);
						}
					}
					if(!f){
						ra t;
						t.b=first;
						t.e=m-1;
						r.push_back(t);
					}
				}
				continue;
			}
			double e=double(V*V-v[i]*v[i])/(2*a[i]);
			//cout<<e<<endl;
			if(a[i]>0){
				
				int h;
				bool f=0;
				for(h=0;h<m;h++){
					if(p[h]>e+d[i]){
						f=1;
						break;
					}
				}
				if(f){ 
					//cout<<h<<" "<<m-1<<endl;
					ans1++;
					f=0;
					for(int j=0;j<(int)r.size();j++){
						if(h>r[j].e){
							continue;
						}else{
							f=1;
							r[j].b=max(r[j].b,h);
						}
					}
					if(!f){
						ra t;
						t.b=h;
						t.e=m-1;
						r.push_back(t);
					}
				}
			}else if(a[i]<0){
				int h,first=-1;
				bool f=0,f1=0;
				for(h=0;h<m;h++){
					if(p[h]>=d[i]&&f1==0){
						first=h;
						f1=1;
						if(p[h]<=e+d[i]){
							//cout<<d[i]<<" "<<e<<" "<<p[h]<<endl;
							f=1;
						}
					}
					if(p[h]>e+d[i]&&h>first){
						
						//f=1;
						break;
					}
				}
				if(first==-1){
					cout<<d[i]<<" "<<e<<" "<<p[h]<<endl;
				}
				
				
				
				if(f) {
					//cout<<first<<" "<<h-1<<endl;
					ans1++;
				
					f=0;
					for(int j=0;j<(int)r.size();j++){
						if(h-1<r[j].b||first>r[j].e){
							continue;
						}else{
							f=1;
							r[j].b=max(r[j].b,first);
							r[j].e=min(r[j].e,h-1);
						}
					}
					if(!f){
						ra t;
						t.b=first;
						t.e=h-1;
						r.push_back(t);
					}
				}
			}
			
		}
		/*for(int i=0;i<(int)r.size();i++){
			cout<<r[i].b<<" "<<r[i].e<<endl;
		}*/
		cout<<ans1<<" ";
		
		if(m-r.size()==0&&zero==1){
			cout<<1<<endl;
		}else cout<<m-r.size()<<endl;
		/*for(int i=0;i<(int)r.size();i++){
			cout<<r[i].b<<" "<<r[i].e<<endl;
		}*/
	}
	return 0;
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 ‐2
6 4 ‐4
2 5 8 9 15
*/
